package com.system.main.dao;

import com.system.main.model.User;
import com.system.main.model.UserRequest;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserDAO {

    @Insert({"insert into user (name, email,password,type) values (#{name}, #{email}, #{password}, #{type})"})
    Integer addUser(UserRequest user);

    @Select({"select id, name, email, type from user where name = #{name} and password = #{password} and type = #{type}"})
    User checkUser(UserRequest user);

    @Select({"select id, name, email, type from user where type = 1"})
    List<User> getAllUsers();

    @Delete({"delete from user where id = #{userId}"})
    Integer deleteUser(Integer userId);

    @Update({"update user set name = #{name}, email = #{email}, type = #{type} where id = #{id}"})
    Integer updatedUser(User user);

    @Select({"select id, name, email, type from user where id = #{userId}"})
    User getUserById(Integer userId);
}
